package com.wenx;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.stream.ChunkedWriteHandler;

/**
 * 初始化连接时候的各个组件
 */
public class MyWebSocketChannelHander extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        socketChannel.pipeline()
                .addLast("http-codec",new HttpServerCodec())
                .addLast("aggregator",new HttpObjectAggregator(65536))
                .addLast("http-chunked",new ChunkedWriteHandler())
                .addLast("handler",new MyWebSocketHandler());
    }
}
